package StudyCode.summary.BufferAndChannel;

import java.nio.ByteBuffer;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GettingBytesFromByteBuffer {
	public static void main(String[] argv) throws Exception {
		ByteBuffer bbuf = ByteBuffer.allocate(10);

		int capacity = bbuf.capacity(); // 10
		System.out.println(capacity);
		byte b = bbuf.get(5); // position=0
		System.out.println(b);
		bbuf.position(5);
		b = bbuf.get();
		System.out.println(b);
		int pos = bbuf.position(); // 6
		System.out.println(pos);
		int rem = bbuf.remaining(); // 4
		System.out.println(rem);
		bbuf.limit(7);
		bbuf.rewind();
	}
}
